package com.shenghui.enterprise.base.entity;

import com.shenghui.enterprise.utils.GeneralUtil;
import com.shenghui.enterprise.utils.ServiceUtil;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

public class Page<T> extends com.baomidou.mybatisplus.extension.plugins.pagination.Page {

    public Page(Map map, HttpServletRequest request) {
        super();
        Integer pageSize = ServiceUtil.getPageSize(ServiceUtil.getDefaultPageSize(20), map, request);
        Integer pageNo = ServiceUtil.getPageNo(0, pageSize, map, request);
        setCurrent(pageNo);
        setSize(pageSize);
        if (GeneralUtil.isNotNull(map.get("order"))) {
            setDesc(map.get("order").toString());
        } else {
            setDesc("create_date");
        }
    }

    public Page(Map map) {
        super();
        Integer pageSize = ServiceUtil.getPageSize(ServiceUtil.getDefaultPageSize(20), map, null);
        Integer pageNo = ServiceUtil.getPageNo(0, pageSize, map, null);
        setCurrent(pageNo);
        setSize(pageSize);
        if (GeneralUtil.isNotNull(map.get("order"))) {
            setDesc(map.get("order").toString());
        } else {
            setDesc("create_date");
        }
    }
}
